﻿using System.Globalization;

namespace ODM.Data.Model
{
    public class QualityControlLevel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="QualityControlLevel"/> class.
        /// </summary>
        public QualityControlLevel()
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="QualityControlLevel"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        public QualityControlLevel(QualityControlLevel source)
        {
            this.ID = source.ID;
            this.Code = source.Code;
            this.Name = source.Name;

        }

        public int ID { get; set; }

        public string Code { get; set; }

        public string Name { get; set; }

        public override string ToString()
        {
            return string.Format(CultureInfo.CurrentUICulture, "{0} - {1}", this.Code, this.Name);
        }


        public static bool operator ==(QualityControlLevel q1, QualityControlLevel q2)
        {
            if (ReferenceEquals(q1, q2))
                return true;
            if (ReferenceEquals(q1, null) || ReferenceEquals(q2, null))
                return false;
            else
                return q1.GetHashCode() == q2.GetHashCode();
        }

        public static bool operator !=(QualityControlLevel q1, QualityControlLevel q2)
        {
            return !(q1 == q2);
        }

        public override bool Equals(object obj)
        {
            QualityControlLevel q = obj as QualityControlLevel;
            if (q == null)
                return false;

            return this == q;
        }

        public override int GetHashCode()
        {
            return string.Format(CultureInfo.InvariantCulture, "QualityControlLevel:{0}{1}{2}", this.ID, this.Code, this.Name).GetHashCode();
        }
    }
}
